package _zifuchuan;

public class _15 {
    public static void main(String[] args) {
        _15 fuck = new _15();
        String s="A man, a plan, a canal: Panama";
        System.out.println(fuck.isPalindrome(s));
    }
    public boolean isPalindrome(String s) {
        int n=s.length();
        int left=0;
        int right = n-1;
        char[] a = s.toCharArray();
        for(int i=0;i<n;i++){
            while(!(a[left]>'a'&&a[left]<'z')||!(a[left]<'Z'&&a[left]>'A')){
                left++;
            }
            while(!(a[right]>'a'&&a[right]<'z')||!(a[right]<'Z'&&a[right]>'A')){
                right--;
            }
            if(a[right]!=a[left]&&Math.abs(a[left]-a[right])!=32){
                return false;
            }
            if(left == right){
                break;
            }
            left++;
            right--;
        }
        return true;
    }
}
